package cn.bocweb.spinning.view.view;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

import cn.bocweb.spinning.util.DeviceUtil;

/**
 * Created by chenchangxing on 16/6/12.
 */
public class CircleViewGroup extends RelativeLayout {

    Canvas mCanvas;

    public CircleViewGroup(Context context) {
        super(context);
    }

    public CircleViewGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onDraw(Canvas canvas) {
        mCanvas = canvas;
        canvas.drawRoundRect(0,
                0,
                getWidth(),
                getHeight(),
                DeviceUtil.dip2px(getContext(), 5),
                DeviceUtil.dip2px(getContext(), 5), new Paint());

        canvas.save();
    }

    public void setBackground(int color) {
        mCanvas.drawColor(getResources().getColor(color));
        invalidate();
    }
}
